package com.xzit.tmms.service.course;


import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.xzit.tmms.bean.unit.Course;
import com.xzit.tmms.common.exception.ServiceException;
import com.xzit.tmms.common.page.Page;
import com.xzit.tmms.mapper.task.ModelMapper;
import com.xzit.tmms.mapper.unit.CourseMapper;

@Service("courseService")
public class CourseServiceImpl implements CourseService {
	@Resource
	private CourseMapper courseMapper;
	
	@Resource
	private ModelMapper modelMapper;
	@Override
	public Page<Map<String, Object>> queryCourse(Page<Map<String, Object>> page) throws ServiceException {
		courseMapper.queryCourse(page);
		return page;
	}

	@Override
	public List<Map<String, Object>> getCourseList() throws ServiceException {
		// TODO Auto-generated method stub
		try {
			return courseMapper.getCourseList();
		} catch (Exception e) {
			throw new ServiceException("");
		}
	}

	@Override
	public void addCourse(Course course) throws ServiceException {
		try {
			courseMapper.save(course);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			throw new ServiceException("增加失败");
		}
		
	}

	@Override
	public List<Map<String, Object>> getModelList() throws ServiceException {
		// TODO Auto-generated method stub
		try {
			return modelMapper.getModelList();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			throw new ServiceException("添加小失败");
		}
	}

	@Override
	public void deleteCourse(Integer courseId) throws ServiceException {
		// TODO Auto-generated method stub
		try {
			courseMapper.delete(courseId);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			throw new ServiceException("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&7删除失败");
		}
	}

	@Override
	public Course getCourseById(Integer courseId) throws ServiceException {
		// TODO Auto-generated method stub
		try {
			return courseMapper.getById(courseId);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			throw new ServiceException("获取教师信息出错");
		}
	}

	@Override
	public void updateCourse(Course course) throws ServiceException {
		try {
			courseMapper.update(course);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	

}
